package net.sxnic.jhitem.itemoperation;

import java.util.LinkedHashMap;
import java.util.List;
import java.util.Map;

import net.sxnic.jhitem.itemoperation.ItemOperation;
import net.sxnic.jhitem.itemoperation.dao.ItemOperationDao;
import net.sxinfo.core.spring25.Dao;
import net.sxinfo.core.spring25.DefaultManager;

import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

@Service("itemOperationManager")
public class DefaultItemOperationManager extends DefaultManager<ItemOperation,ItemOperationDao,String>
		implements ItemOperationManager{

	@Autowired
	private ItemOperationDao itemOperationDao;
	@Override
	protected Dao<ItemOperation, String> getEntityDao() {
		return itemOperationDao;
	}
	
	/**
	 * 根据项目的计划类别获取页面路径
	 * @param catalog1 大类别
	 * @param catalog2 小类别
	 * @param soperCode 计划类别
	 * @return 页面路径
	 */
	public String findJspCatalog(String catalog1,String catalog2,String soperCode)
	{
		return itemOperationDao.findJspCatalog(catalog1, catalog2, soperCode);
	}
	
	/**
	 * 获取计划类别Map
	 * @return 计划类别Map
	 */
	public Map<String,String> findOperationMap()
	{
		Map<String,String> map = new LinkedHashMap<String,String>();
		List<ItemOperation> operationList = this.getAll();
		if(operationList!=null&&operationList.size()>0)
		{
			for(ItemOperation operation : operationList)
			{
				map.put(operation.getSoperCode(), operation.getSoperName());
			}
		}
		return map;
	}
	
	/**
	 * 获取计划类别简称Map
	 * @return 计划类别简称Map
	 */
	public Map<String,String> findOperationShortnameMap()
	{
		Map<String,String> map = new LinkedHashMap<String,String>();
		List<ItemOperation> operationList = this.getAll();
		if(operationList!=null&&operationList.size()>0)
		{
			for(ItemOperation operation : operationList)
			{
				map.put(operation.getSoperCode(), operation.getSoperShortname());
			}
		}
		return map;
	}
	
	/**
	 * 根据部门编码获取实体列表
	 * @param catalog1 大类别
	 * @param catalog2 小类别
	 * @param deptCode 处室编码
	 * @return 部门编码对应的实体列表
	 */
	public List<ItemOperation> findSoperCode(String catalog1,String catalog2,String deptCode)
	{
		return itemOperationDao.findSoperCode(catalog1, catalog2, deptCode);
	}
}
